package com.yuelao.aop;

import org.apache.ibatis.javassist.CannotCompileException;
import org.apache.ibatis.javassist.ClassPool;
import org.apache.ibatis.javassist.Loader;
import org.apache.ibatis.javassist.NotFoundException;

/**
 * 自定义aop测试
 */
public class AopTest {
    public static void main(String[] args) {
        //获取存放CtClass的容器ClassPool
        ClassPool cp = ClassPool.getDefault();
        //创建一个类加载器
        Loader cl = new Loader();
        //增加一个转换器
        try {
            cl.addTranslator(cp, new MyTranslator());
        } catch (NotFoundException e) {
            e.printStackTrace();
        } catch (CannotCompileException e) {
            e.printStackTrace();
        }
        try {
            //启动MyTranslator的main函数
            cl.run("com.yuelao.aop.MyTranslator", args);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }
}
